﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;
using System.Collections.Generic;

namespace ProtetoresDaMata.Objects
{
    public abstract class Sprite
    {
        // The texture for the sprite
        public Texture2D Texture;

        // Our textures contain shadows, so this specifies the actual area that is collideable
        public Rectangle CollisionBounds;

        public Vector2 Position;
        public float Mass;


        /// <summary>
        /// Positions the sprite centered in the ground.
        /// </summary>
        public void CenterAt()
        {
            Position = new Vector2(0f, 0f);
        }

        /// <summary>
        /// Positions the sprite centered on the given point.
        /// </summary>
        /// <param name="center">The location on which to center the sprite.</param>
        public void CenterAtLocation(Vector2 center)
        {
            Position = center - new Vector2(Texture.Width / 2, Texture.Height / 2);
        }
        
        /// <summary>
        /// Allows the sprite to load content.
        /// </summary>
        /// <param name="content">The ContentManager used to load content.</param>
        public virtual void LoadPropertiesDefault(ContentManager content) { }

        /// <summary>
        /// Draws the sprite.
        /// </summary>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, Color.White);
        }

        /// <summary>
        /// Methods for get the retangle bounds of the sprite
        /// </summary>
        /// <param name="sprite"></param>
        /// <returns></returns>
        public Rectangle GetRetangleBounds(Sprite sprite)
        {
            if (sprite != null)
                return new Rectangle((int)sprite.Position.X,
                                     (int)sprite.Position.Y,
                                     sprite.Texture.Width,
                                     sprite.Texture.Height);

            return new Rectangle();
        }

    }
}
